package bb.lanxing.util.ui

import android.content.Context
import android.view.LayoutInflater
import bb.lanxing.R
import bb.lanxing.databinding.FragmentBottomSheetTipsWithIndicatorBinding
import bb.lanxing.databinding.LayoutXpairIntroItemBinding
import com.google.android.material.bottomsheet.BottomSheetDialog
import java.io.Serializable
import kotlin.jvm.internal.Intrinsics

object IndicatorTipsBottomSheetDialog {
    fun show(
        context: Context, inflater: LayoutInflater, indicatorTipsBean: IndicatorTipsBean
    ) {
        val bottomSheetDialog = BottomSheetDialog(context, R.style.TransparentBottomSheetStyle)
        val binding: FragmentBottomSheetTipsWithIndicatorBinding =
            FragmentBottomSheetTipsWithIndicatorBinding.inflate(inflater, null, false)
        for ((index, item) in indicatorTipsBean.tips.withIndex()) {
            val inflate: LayoutXpairIntroItemBinding = LayoutXpairIntroItemBinding.inflate(inflater)
            Intrinsics.checkNotNullExpressionValue(inflate, "inflate(inflater)")
            inflate.tvIndex.text = (index + 1).toString()
            inflate.tvContent.text = item
            binding.llContent.addView(inflate.getRoot())
        }
        binding.tvClose.setOnClickListener {
            bottomSheetDialog.dismiss()
        }
        bottomSheetDialog.setContentView(binding.getRoot())
        bottomSheetDialog.show()
    }

    class IndicatorTipsBean(tips: List<String>) : Serializable {
        val tips: List<String> = tips
    }
}